package com.didd.core.constant.enums;


import com.didd.core.dict.core.DictEnumInterface;

/**
 * 用户性别: 0女，1男，2其它
 *
 * @author diddd
 * @since 2021/11/09
 */
public enum SexEnum implements DictEnumInterface {

    /**
     * 女
     */
    FEMALE("0", "女"),

    /**
     * 男
     */
    MALE("1", "男"),

    /**
     * 其他
     */
    OTHER("2", "其他"),

    //未知
    UNKNOWN("-1", "未知");

    private String code;

    private String name;


    SexEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getName() {
        return name;
    }

    public static SexEnum getEnum(String code) {
        for (SexEnum item : SexEnum.values()) {
            if (item.getCode().equals(code)) {
                return item;
            }
        }
        return UNKNOWN;
    }

    public static SexEnum getEnum(Integer code) {
        for (SexEnum item : SexEnum.values()) {
            if (item.getCode().equals(String.valueOf(code))) {
                return item;
            }
        }
        return UNKNOWN;
    }

}

